/*
 * @Author: yc yangcheng960813@163.com
 * @Date: 2022-09-28 22:04:07
 * @LastEditTime: 2023-02-12 16:50:17
 * @LastEditors: Crazy_Debug yangcheng960813@163.com
 * @Description: 
 * @FilePath: /shaonao2/assets/libs/singleton/Singleton.ts
 * 可以输入预定的版权声明、个性签名、空行等
 */
export default function Singleton<T>() {
    class SingletonE {
        protected constructor() {
        }

        protected static instance: SingletonE = null;

        public static get i(): T {
            if (SingletonE.instance == null) {
                SingletonE.instance = new this();
            }
            return SingletonE.instance as T;
        }
    }

    return SingletonE;
}

// export default abstract class Singleton<T> {
//     private static m_ins = null;
//     // public static i<T extends {}>(this: new () => T): T {
//     //     if (!(<any>this).m_ins) (<any>this).m_ins = new this();
//     //     return (<any>this).m_ins;
//     // }
// }